﻿// License: https://opensource.org/licenses/MIT
// Create Date : 2018-01-01

using System.Collections.Concurrent;

namespace Cat.Core.XLog
{
    public abstract class LogProviderWithCache : LogProviderBase
    {
        protected ConcurrentDictionary<string, ILogger> Cache { get; set; }
            = new ConcurrentDictionary<string, ILogger>();
        protected override ILogger GetLoggerCore(string name)
        {
            return Cache.GetOrAdd(name, t => CreateLoggerCore(t));
        }
        protected abstract ILogger CreateLoggerCore(string name);
    }
}
